<!DOCTYPE html>
<html lang="zh-CN">
<meta charset="utf-8" />
<head>
<title>分配权限 <?php echo $this->config->item('title');?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet"	href="<?php echo base_url()?>public/css/bootstrap.min.css">
<link rel="stylesheet" href="<?php echo base_url()?>public/css/style.css">
</head>
<body>
	<script src="<?php echo base_url()?>public/js/jquery-2.0.2.min.js"></script>
	<script src="<?php echo base_url()?>public/js/bootstrap.min.js"></script>
	<script src="<?php echo base_url()?>public/js/bootstrap-confirm.js"></script>
	<script src='<?php echo base_url()?>public/js/bootbox.min.js'></script>
	<script src='<?php echo base_url()?>public/js/jquery.form.js'></script>
	<script src='<?php echo base_url()?>public/js/ssi_common.js'></script>
	<script type="text/javascript">
	jQuery(function($) {
		$('#main_from').ajaxForm({
			dataType:  'json',
			beforeSubmit:  showRequest,
			success:   processJson
		});
	
		function showRequest(formData, jqForm, options) {
		}
	
		function processJson(data) {
			if (data.result==false) {
				bootbox.alert(data.message, function() {
				});
				$('button[type="submit"]').removeClass('disabled');
			}else{
				window.location.href=data.redirect_url;
			}
		}

		$(".right_list").click(function(){
			if($(this).prop("checked")==true){
				$(this).parent().siblings().find("input").prop("checked",true);
			}else{
				$(this).parent().siblings().find("input").prop("checked",false);
			}
		});
		$(".action_list").click(function(){
			if($(this).prop("checked")==true){
				$(this).parent().siblings().find("input").prop("checked",true);
			}else{
				var checked=false;
				$(this).siblings().each(function(){
					if($(this).prop("checked")==true){
						checked=true;
				   	}
				});
				if (checked==false) {
					$(this).parent().siblings().find("input").prop("checked",false);
				}
			}
		});
	});
	</script>
	<div role="navigation" class="navbar navbar-inverse navbar-fixed-top">
		<div class="container">
			<div class="navbar-header">
				<a class="navbar-brand">SSI后台管理系统</a>
			</div>
			<div class="collapse navbar-collapse navbar-right">
				<ul class="nav navbar-nav">
					<li><a href="<?php echo base_url()?>" class="navbar-link">首页</a></li>
					<li><a href="<?php echo base_url()."index.php/common_login_user_set"?>" class="navbar-link">超级管理员</a></li>
					<li><a href="<?php echo base_url()?>index.php/common_login_manage/logout" class="navbar-link">退出</a></li>
				</ul>
			</div>
		</div>
	</div>
	<div class="container">
		<div class="row">
			<div class="col-xs-3">
				<?php echo $user_menu?>
			</div>
			<div class="col-md-9">
				<div class="panel panel-default">
					<div class="panel-heading">分配权限</div>
					<div class="panel-body">
						<form method="post" enctype="multipart/form-data" id="main_from" action="<?php echo base_url()?>index.php/common_role_manage/assign_right" class="form-horizontal">
							 <?php for ($i = 0; $i < count($module_list); $i++) {?>
									<input type="hidden" name="right_id[]" value="<?php echo $module_list[$i]['right_id']?>">
									<table id="table_liquid" cellspacing="0" >
			                                    <tbody>
				                                <?php  $alt =1;	
				                                for ($j = 0; $j < count($right_list); $j++) {?>
				                                	<?php if ($right_list[$j]['parent_id']==$module_list[$i]['right_id']) {?>
				                                   	<tr>
					                                    <th  width="110px" align="right">
					                                    	<label for="right_id<?php echo $right_list[$j]['right_id']?>" class="inline"><?php echo $right_list[$j]['name']?></label>
					                                    	<input type="checkbox" class="right_list" value="<?php echo $right_list[$j]['right_id']?>" name="right_id[]" id="right_id<?php echo $right_list[$j]['right_id']?>" <?php if (in_array($right_list[$j]['right_id'], $role_right)){echo "checked=\"checked\"";}?> >
					                                    </th>
					                                    <td >
					                                    <?php for ($j2 = 0; $j2 < count($right_list); $j2++) {?>
						                                    <?php if ($right_list[$j2]['parent_id']==$right_list[$j]['right_id']) {?>
						                                    	<input type="checkbox" class="action_list" value="<?php echo $right_list[$j2]['right_id']?>" name="right_id[]" id="<?php echo $right_list[$j2]['right_id']?>" <?php if (in_array($right_list[$j2]['right_id'], $role_right)){echo "checked=\"checked\"";}?>>
						                                    	<label for="<?php echo $right_list[$j2]['right_id']?>" class="inline"><?php echo $right_list[$j2]['name']?></label>
						                                    <?php }?>	
					                                    <?php }?>
					                                    </td>
				                                    </tr>
				                                	<?php $alt=$alt+1;}?>
				                                <?php }?>
			                            		</tbody>
			                       </table>
							<?php }?>
							<input type="hidden" name ="role_id" value="<?php echo $role_info['role_id']?>">
							<div class="form-group">
								<div class="col-sm-offset-3 col-sm-10">
									<button type="button" onclick='from_check_login($("#main_from"),"<?php echo base_url()?>")' class="btn btn-primary">编辑</button>
									<a href="javascript:void()" onclick='history.back()' >返回</a>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
<div  class="back-to" id="toolBackTop">
	<a title="返回顶部" onclick="window.scrollTo(0,0);return false;" href="#top" class="back-top">
	返回顶部</a>
	<a title="返回底部" onclick="window.scrollTo(0,document.body.scrollHeight);return false;" href="#bottom" class="back-bottom">
	返回底部</a>
</div>
</body>
</html>
